/**
 * 合并reducers 
 * @param {*} reducers 对象 
 */
export default function combineReducers(reducers) {
    // 会返回一个函数，作为createStore的第一个参数
    // 获得reducers中所有的属性
    const keys = Object.keys(reducers);
    return function (state = {}, action) {
        const storeState = {};
        for (let prop of keys) {
            // 执行对应的reducer得到各自的状态state
            storeState[prop] = reducers[prop](state[prop], action);
        }
        return storeState;
    }
}